package homeWork;

import java.util.Scanner;

public class homeWork12 {
    public static void main(String[] args){
        //递归求斐波那契数列的第 N 项
        System.out.println("输入一个整数 N:");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println("斐波那契数列的第 " + n + " 项为：" + fibonacci(n));
    }
    public static int fibonacci(int n){
        if (n == 1 || n == 2){
            return 1;
        }else{
            return fibonacci(n - 1) + fibonacci(n - 2);
        }
    }

}
